package cn.neusoft.service.impl;

import cn.neusoft.po.RolePermission;
import cn.neusoft.mapper.RolePermissionMapper;
import cn.neusoft.service.IRolePermissionService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author hxj
 * @since 2023-12-19
 */
@Service
public class RolePermissionServiceImpl extends ServiceImpl<RolePermissionMapper, RolePermission> implements IRolePermissionService {

    @Override
    public boolean changeRolePermission(Integer roleId, List<RolePermission> rolePermissions) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("role_id",roleId);
        int delete = baseMapper.delete(queryWrapper);
        if (delete>0){
           return saveBatch(rolePermissions);
        }
        return false;
    }
}
